<?php
namespace app\common\model;
use think\facade\Cache;
use think\Model;
class State extends Model {
    public function getStatusTextAttr($value,$data)
    {
        $status = [1=>'<span class="label label-success">正常</span>',2=>'<span class="label label-danger">禁用</span>'];
        return $status[$data['status']];
    }
/**
 * 返回缓存后的状态
 * 调用所有的状态
 * @return array
 */
public static function getState(){
    $data = Cache::tag('state')->get('statedata');
    if(!$data){
        $data=model('state')->column('name','id');
        Cache::tag('state')->set('statedata',$data);
    }
    return $data;
    }
}